﻿#ifndef MAINUI_H
#define MAINUI_H
#pragma once
#include <QWidget>
#include <QList>
#include <QTreeWidgetItem>
#include <mypdu.h>
#include "login.h"
#include <QListWidgetItem>
#include <QMouseEvent>
#include <QFile>
#include "personinfoui.h"

namespace Ui {
class MainUI;
}

class MainUI : public QWidget
{
    Q_OBJECT

public:
    explicit MainUI(QWidget *parent = nullptr);
    ~MainUI();
    static MainUI& getInstance();
    void    loadFriend(QList<userInfo>);
    void    loadGroup(QList<groupinfo> info);
    void    updateFriendList(userInfo u,int msg,QString strmsg);//更新好友列表
    void    updateGroupList(userInfo u,int msg,QString strmsg,QString gname="");//更新群列表
    void    setNickName(QString name);//设置昵称
    void    setHead(QString uname);//设置头像
    bool    getStatus(QString name);
    void    loadGroupMsg(PDU* pdu,QString msg);//加载群消息
    QListWidget* getFriendList();//获取好友列表
    QString    getNickName();//获取昵称
private slots:
    void on_btn_addFriend_clicked();

    void on_MainUI_destroyed();

    void on_pushButton_clicked();

    void mousePressEvent(QMouseEvent *event);//鼠标点击

    void mouseMoveEvent(QMouseEvent *event);//鼠标移动

    void mouseReleaseEvent(QMouseEvent *event);//鼠标释放

    void on_toolButton_2_clicked();

    void on_friend_list_itemDoubleClicked(QListWidgetItem *item);

    void on_toolButton_clicked();

    void on_friendId_textChanged(const QString &arg1);

    void on_search_list_itemDoubleClicked(QListWidgetItem *item);



    void on_pushButton_2_clicked();

    void on_list_group_itemDoubleClicked(QListWidgetItem *item);

private:
    bool isPressedWidget;//isPressedWidget和last用来控制窗口移动
    QPoint last;
    QAction m_ac1;//搜索标记
    QList<QListWidgetItem*> m_listwidgetitem;//用于辅助搜索功能
    Ui::MainUI *ui;
    //PersonInfoUI* m_personInfoUI;
};

#endif // MAINUI_H
